package pro.cherish.knowledgerabbitmqproducer.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 创建人：lys
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2020-3-22 lys 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：BeanConfig
 * @Description 功能说明：
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2020-3-22
 */
@Data
@Configuration
public class BeanConfig {
    @Data
    @AllArgsConstructor
    public class B {
        private A a;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public class A {
        private Integer num = 3;
    }

    @Data
    @AllArgsConstructor
    public class C {
        private A a;
    }

    @Bean(value = "cherishA")
    public A createA() {
        return new A();
    }

    @Bean
    public B createB() {
        return new B(createA());
    }

    @Bean
    public C createC(@Qualifier(value = "cherishA") A a) {
        return new C(a);
    }
}
